﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Kevin.Framework.Validation
{
    /// <summary>
    /// 对象不为空的校验器属性类
    /// </summary>
    /// <remarks>
    /// 对象不为空的校验器属性类
    /// </remarks>
    [AttributeUsage(AttributeTargets.Property
       | AttributeTargets.Field | AttributeTargets.Class,
       AllowMultiple = true,
       Inherited = false)]
    public sealed class NotNullValidatorAttribute : ValidatorAttribute
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public NotNullValidatorAttribute()
        {
        }

        /// <summary>
        /// 重载基类的方法，调用NotNullValidator的构造方式创建一个NotNullValidator实例
        /// </summary>
        /// <param name="targetType">目标类型，在本默认实现中未使用到该参数</param>
        /// <returns>NotNullValidator实例</returns>
        protected override Validator DoCreateValidator(Type targetType)
        {
            return new NotNullValidator();
        }
    }
}
